import request from '@/utils/request';
import type { LoginForm, UserInfo } from './type';
import type { ResponseType } from '../common/type';
/**
 * 用户api常量
 */
enum UserConstant {
	LOGIN_URL = '/admin/acl/index/login',
	USERINFO_URL = '/admin/acl/index/info',
	LOGOUT_URL = '/admin/acl/index/logout',
}
/**
 * 用户登陆api
 * @param loginForm 账号密码
 * @returns Promise对象
 */
export let reqLogin = (loginForm: LoginForm): Promise<ResponseType<string>> => {
	return request.post(UserConstant.LOGIN_URL, loginForm);
};
/**
 * 获取用户信息
 * @returns Promise对象
 */
export let reqUserInfo = (): Promise<ResponseType<UserInfo>> => {
	return request.get(UserConstant.USERINFO_URL);
};

/**
 * 退出登录
 * @returns Promise对象
 */
export let reqLogout = (): Promise<any> => {
	return request.delete(UserConstant.LOGOUT_URL);
};
